package com.kkb.configurations;

import com.kkb.interceptors.OnlineInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorAdder implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        InterceptorRegistration registration = registry.addInterceptor(new OnlineInterceptor());
        registry.addInterceptor(new OnlineInterceptor()).
                addPathPatterns("/**").
                excludePathPatterns(
                        "/",
                        "/login.do",
                        "/toLogin.do",
                        "/css/**",
                        "/js/**",
                        "/index/**",
                        "/media/**",
                        "/vendor/**",
                        "/static/**"
                );
    }
//    @Override
//    public void addViewControllers(ViewControllerRegistry registry) {
//        registry.addViewController("/").setViewName("index");
//        registry.addViewController("/toLogin.do").setViewName("login");
//    }
}
